﻿using System;
using System.IO;

namespace DivShare
{
    /// <summary>
    /// Provides data for the <see cref="E:OpenWebFileCompleted"/> event of a <see cref="DivShareClient"/>.
    /// </summary>
    public class OpenWebFileCompletedEventArgs : EventArgs
    {
        /// <summary>
        /// Gets a value indicating which error occurred during opening webfile.
        /// </summary>
        /// <value>An <see cref="Exception"/> instance, if an error occurred during opening webfile; otherwise <c>null</c>.</value>
        public Exception Error { get; protected set; }

        /// <summary>
        /// Gets a readable stream that contains webfile's data downloaded by a <see cref="M:DownloadWebFileAsync"/> method.
        /// </summary>
        /// <value>A <see cref="Stream"/> that contains the downloaded webfile's data.</value>
        public Stream WebFileStream { get; protected set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="OpenWebFileCompletedEventArgs"/> class.
        /// </summary>
        /// <param name="wfStream">The readable stream that contains webfile's data.</param>
        /// <param name="ex">The exception occured during opening webfile.</param>
        internal OpenWebFileCompletedEventArgs(Stream wfStream, Exception ex)
        {
            WebFileStream = wfStream;
            Error = ex;
        }
    }
}
